import request from "../request";

// 用户登录
interface UserLoginData {
  account: string;
  password: string;
  name: string;
  avatar: string;
}
export const userLogin = (data: UserLoginData) => {
  return request("/front/login", data, "POST");
};

// 搜索文章
interface SearchData {
  articleId?: number;
  content?: string;
}
export const searchArticle = (data: SearchData) => {
  console.log(data);
  const url = "/front/article/single?content=" + data.content;
  return request(url, {}, "GET");
};

// 获取评论
export const getComment = (articleId: string) =>
  request("/front/comment?articleId=" + articleId, {}, "GET");

// 添加评论
interface CommentData {
  date: string;
  content: string;
  parentId: number;
  level: number;
  articleId: string | undefined;
  id: number;
}
export const addComment = (data: CommentData) =>
  request("/front/comment/api", data, "POST");

// 获取聊天
export const getChat = () => request("/front/chat", {}, "GET");

// 发布消息
interface ChatData {
  userId: string;
  content: string;
}
export const addChat = (data: ChatData) =>
  request("/front/chat/api", data, "POST");

// AI聊天
interface AiData {
  data: string;
}
export const aiChat = (data: AiData) => request("/front/Ai", data, "POST");
